//
//  THJExpressVC.m
//  THJXHW
//
//  Created by 河南德艺 on 17/4/6.
//  Copyright © 2017年 河南德艺. All rights reserved.
//

#import "THJExpressVC.h"
#import "THJWebviewVC.h"

@interface THJExpressVC (){
    UITableView * _tableview;
}
@end

@implementation THJExpressVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"物流查询";
    [self setGoBackBtn];
    self.view.backgroundColor = COLOR(244, 244, 244, 1);
    self.textfiled.backgroundColor = SingleColor(whiteColor);
    NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:@"请输入物流编号" attributes:
                                      @{NSForegroundColorAttributeName:[UIColor lightGrayColor],
                                        }];
    self.textfiled.attributedPlaceholder = attrString;
}
-(void)viewWillAppear:(BOOL)animated{
    self.tabBarController.tabBar.hidden = YES;
    [super viewWillAppear:animated];
    //[MobClick beginLogPageView:@"物流page"];
}
- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
   // [MobClick endLogPageView:@"物流page"];
}
- (IBAction)searchClicked:(id)sender {
    if([self.textfiled.text isEqual:@""]){
        [self HUDShowMsg:@"请输入物 流编号" AfterDelayDimiss:1];
        return;
    }
    [MBProgressHUD showMessage:@"正在查询" toView:self.view];
    NSString * token = [THJTools getToken];
    NSString * orderno = [self.textfiled.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSString * urlstr = [NSString stringWithFormat:@"%@%@%@%@%@%@%@",THJDomain,THJindexPHP,@"action=validorderno",@"&orderno=",orderno,@"&token=",token];
    __weak typeof(self) weakself = self;
    NSLog(@"wuliu-%@",urlstr);
    [THJNetWork getCompanyIntroFromUrl:urlstr callback:^(NSDictionary* receiveData, NSError *error) {
         [MBProgressHUD hideHUDForView:weakself.view];
        if (!error) {
            if ([receiveData[@"state"] isEqual:@"fail"]) {
                [weakself HUDShowMsg:receiveData[@"message"] AfterDelayDimiss:1];
            }else{
                weakself.textfiled.text = @"";
                NSString * urlstr = [NSString stringWithFormat:@"http://www.thjb.net/wl/path.php?wl_kw=%@",orderno];
                THJWebviewVC * vc = [[THJWebviewVC alloc] init];
                vc.IsComeFromPush = NO;
                vc.title = @"物流轨迹";
                vc.detailUrl = urlstr;
                [weakself.navigationController pushViewController:vc animated:YES];
            }
        }
    }Type:2];
}
@end
